import 'package:flutter/material.dart';
import 'package:todo_app/constants/DColor.dart';
import 'package:todo_app/layout/Gaps.dart';

extension TextExt on Text {
  static TextStyle defaultTitleStyle = TextStyle(color: DColor.title, fontSize: 14.dp, height: 20 / 14);
  static TextStyle defaultBodyStyle = TextStyle(color: DColor.body, fontSize: 14.dp, height: 20 / 14);
  static TextStyle defaultDescStyle = TextStyle(color: DColor.descText, fontSize: 12.dp, height: 20 / 12);

  /// 生成标题
  static Text title(String title, {
    TextStyle? style,
    TextAlign? textAlign,
    TextOverflow? overflow,
    bool bold = false,
    double? lineHeight,
    double? fontSize,
    int? maxLines,
  }) {
    var boldStyle = TextStyle(
      fontWeight: bold ? FontWeight.bold : FontWeight.w400,
      height: lineHeight ?? 1,
      fontSize: fontSize
    );
    return Text(
      title, 
      style: defaultTitleStyle.merge(boldStyle).merge(style), 
      textAlign: textAlign, 
      overflow: overflow,
      maxLines: maxLines,
    );
  }
  /// 生成普通文本
  static Text body(String body, {
    TextStyle? style,
    TextAlign? textAlign,
    TextOverflow? overflow,
    bool bold = false,
    double? lineHeight,
    double? fontSize,
    int? maxLines,
  }) {
    var boldStyle = TextStyle(
      fontWeight: bold ? FontWeight.bold : FontWeight.w400,
      height: lineHeight ?? 1,
      fontSize: fontSize,
    );
    return Text(body, style: defaultBodyStyle.merge(boldStyle).merge(style), textAlign: textAlign, overflow: overflow, maxLines: maxLines,);
  }
  /// 生成描述文本
  static Text desc(String desc, {
    TextStyle? style,
    TextAlign? textAlign,
    TextOverflow? overflow,
    bool bold = false,
    double? lineHeight,
    double? fontSize,
     int? maxLines,
  }) {
    var boldStyle = TextStyle(
      fontWeight: bold ? FontWeight.bold : FontWeight.w400,
      height: lineHeight ?? 1,
      fontSize: fontSize
    );
    return Text(desc, style: defaultDescStyle.merge(boldStyle).merge(style), textAlign: textAlign, overflow: overflow, maxLines: maxLines,);
  }
}